$content = $this->getPreloadedContent( $preload, $params );
}
// For existing pages, get text based on "undo" or section parameters.
- } else {
- if ( $this->section != '' ) {
- // Get section edit text (returns $def_text for invalid sections)
- $orig = $this->getOriginalContent( $user );
- $content = $orig ? $orig->getSection( $this->section ) : null;
+ } elseif ( $this->section != '' ) {
+ // Get section edit text (returns $def_text for invalid sections)
+ $orig = $this->getOriginalContent( $user );
+ $content = $orig ? $orig->getSection( $this->section ) : null;
- if ( !$content ) {
- $content = $def_content;
- }
- } else {
- $undoafter = $request->getInt( 'undoafter' );
- $undo = $request->getInt( 'undo' );
-
- if ( $undo > 0 && $undoafter > 0 ) {
- $undorev = Revision::newFromId( $undo );
- $oldrev = Revision::newFromId( $undoafter );
- $undoMsg = null;
-
- # Sanity check, make sure it's the right page,
- # the revisions exist and they were not deleted.
- # Otherwise, $content will be left as-is.
- if ( !is_null( $undorev ) && !is_null( $oldrev ) &&
- !$undorev->isDeleted( Revision::DELETED_TEXT ) &&
- !$oldrev->isDeleted( Revision::DELETED_TEXT )
+ if ( !$content ) {
+ $content = $def_content;
+ }
+ } else {
+ $undoafter = $request->getInt( 'undoafter' );
+ $undo = $request->getInt( 'undo' );
+
+ if ( $undo > 0 && $undoafter > 0 ) {
+ $undorev = Revision::newFromId( $undo );
+ $oldrev = Revision::newFromId( $undoafter );
+ $undoMsg = null;
+
+ # Sanity check, make sure it's the right page,
+ # the revisions exist and they were not deleted.
+ # Otherwise, $content will be left as-is.
+ if ( !is_null( $undorev ) && !is_null( $oldrev ) &&
+ !$undorev->isDeleted( Revision::DELETED_TEXT ) &&
+ !$oldrev->isDeleted( Revision::DELETED_TEXT )
+ ) {
+ if ( WikiPage::hasDifferencesOutsideMainSlot( $undorev, $oldrev )
+ || !$this->isSupportedContentModel( $oldrev->getContentModel() )
) {
- if ( WikiPage::hasDifferencesOutsideMainSlot( $undorev, $oldrev )
- || !$this->isSupportedContentModel( $oldrev->getContentModel() )
- ) {
- // Hack for undo while EditPage can't handle multi-slot editing
- $this->context->getOutput()->redirect( $this->mTitle->getFullURL( [
- 'action' => 'mcrundo',
- 'undo' => $undo,
- 'undoafter' => $undoafter,
- ] ) );
- return false;
- } else {
- $content = $this->page->getUndoContent( $undorev, $oldrev );
+ // Hack for undo while EditPage can't handle multi-slot editing
+ $this->context->getOutput()->redirect( $this->mTitle->getFullURL( [
+ 'action' => 'mcrundo',
+ 'undo' => $undo,
+ 'undoafter' => $undoafter,
+ ] ) );
+ return false;
+ } else {
+ $content = $this->page->getUndoContent( $undorev, $oldrev );
- if ( $content === false ) {
- # Warn the user that something went wrong
- $undoMsg = 'failure';
- }
+ if ( $content === false ) {
+ # Warn the user that something went wrong
+ $undoMsg = 'failure';
}
+ }
- if ( $undoMsg === null ) {
- $oldContent = $this->page->getContent( Revision::RAW );
- $popts = ParserOptions::newFromUserAndLang(
- $user, MediaWikiServices::getInstance()->getContentLanguage() );
- $newContent = $content->preSaveTransform( $this->mTitle, $user, $popts );
- if ( $newContent->getModel() !== $oldContent->getModel() ) {
- // The undo may change content
- // model if its reverting the top
- // edit. This can result in
- // mismatched content model/format.
- $this->contentModel = $newContent->getModel();
- $this->contentFormat = $oldrev->getContentFormat();
- }
+ if ( $undoMsg === null ) {
+ $oldContent = $this->page->getContent( Revision::RAW );
+ $popts = ParserOptions::newFromUserAndLang(
+ $user, MediaWikiServices::getInstance()->getContentLanguage() );
+ $newContent = $content->preSaveTransform( $this->mTitle, $user, $popts );
+ if ( $newContent->getModel() !== $oldContent->getModel() ) {
+ // The undo may change content
+ // model if its reverting the top
+ // edit. This can result in
+ // mismatched content model/format.
+ $this->contentModel = $newContent->getModel();
+ $this->contentFormat = $oldrev->getContentFormat();
+ }
- if ( $newContent->equals( $oldContent ) ) {
- # Tell the user that the undo results in no change,
- # i.e. the revisions were already undone.
- $undoMsg = 'nochange';
- $content = false;
- } else {
- # Inform the user of our success and set an automatic edit summary
- $undoMsg = 'success';
-
- # If we just undid one rev, use an autosummary
- $firstrev = $oldrev->getNext();
- if ( $firstrev && $firstrev->getId() == $undo ) {
- $userText = $undorev->getUserText();
- if ( $userText === '' ) {
- $undoSummary = $this->context->msg(
- 'undo-summary-username-hidden',
- $undo
- )->inContentLanguage()->text();
- } else {
- $undoSummary = $this->context->msg(
- 'undo-summary',
- $undo,
- $userText
- )->inContentLanguage()->text();
- }
- if ( $this->summary === '' ) {
- $this->summary = $undoSummary;
- } else {
- $this->summary = $undoSummary . $this->context->msg( 'colon-separator' )
- ->inContentLanguage()->text() . $this->summary;
- }
- $this->undidRev = $undo;
+ if ( $newContent->equals( $oldContent ) ) {
+ # Tell the user that the undo results in no change,
+ # i.e. the revisions were already undone.
+ $undoMsg = 'nochange';
+ $content = false;
+ } else {
+ # Inform the user of our success and set an automatic edit summary
+ $undoMsg = 'success';
+
+ # If we just undid one rev, use an autosummary
+ $firstrev = $oldrev->getNext();
+ if ( $firstrev && $firstrev->getId() == $undo ) {
+ $userText = $undorev->getUserText();
+ if ( $userText === '' ) {
+ $undoSummary = $this->context->msg(
+ 'undo-summary-username-hidden',
+ $undo
+ )->inContentLanguage()->text();
+ } else {
+ $undoSummary = $this->context->msg(
+ 'undo-summary',
+ $undo,
+ $userText
+ )->inContentLanguage()->text();
+ }
+ if ( $this->summary === '' ) {
+ $this->summary = $undoSummary;
+ } else {
+ $this->summary = $undoSummary . $this->context->msg( 'colon-separator' )
+ ->inContentLanguage()->text() . $this->summary;
}
- $this->formtype = 'diff';
+ $this->undidRev = $undo;
}
+ $this->formtype = 'diff';
}
- } else {
- // Failed basic sanity checks.
- // Older revisions may have been removed since the link
- // was created, or we may simply have got bogus input.
- $undoMsg = 'norev';
}
-
- $out = $this->context->getOutput();
- // Messages: undo-success, undo-failure, undo-main-slot-only, undo-norev,
- // undo-nochange.
- $class = ( $undoMsg == 'success' ? '' : 'error ' ) . "mw-undo-{$undoMsg}";
- $this->editFormPageTop .= Html::rawElement(
- 'div', [ 'class' => $class ],
- $out->parseAsInterface(
- $this->context->msg( 'undo-' . $undoMsg )->plain()
- )
- );
+ } else {
+ // Failed basic sanity checks.
+ // Older revisions may have been removed since the link
+ // was created, or we may simply have got bogus input.
+ $undoMsg = 'norev';
}
- if ( $content === false ) {
- // Hack for restoring old revisions while EditPage
- // can't handle multi-slot editing.
+ $out = $this->context->getOutput();
+ // Messages: undo-success, undo-failure, undo-main-slot-only, undo-norev,
+ // undo-nochange.
+ $class = ( $undoMsg == 'success' ? '' : 'error ' ) . "mw-undo-{$undoMsg}";
+ $this->editFormPageTop .= Html::rawElement(
+ 'div', [ 'class' => $class ],
+ $out->parseAsInterface(
+ $this->context->msg( 'undo-' . $undoMsg )->plain()
+ )
+ );
+ }
- $curRevision = $this->page->getRevision();
- $oldRevision = $this->mArticle->getRevisionFetched();
+ if ( $content === false ) {
+ // Hack for restoring old revisions while EditPage
+ // can't handle multi-slot editing.
- if ( $curRevision
- && $oldRevision
- && $curRevision->getId() !== $oldRevision->getId()
- && ( WikiPage::hasDifferencesOutsideMainSlot( $oldRevision, $curRevision )
- || !$this->isSupportedContentModel( $oldRevision->getContentModel() ) )
- ) {
- $this->context->getOutput()->redirect(
- $this->mTitle->getFullURL(
- [
- 'action' => 'mcrrestore',
- 'restore' => $oldRevision->getId(),
- ]
- )
- );
+ $curRevision = $this->page->getRevision();
+ $oldRevision = $this->mArticle->getRevisionFetched();
- return false;
- }
- }
+ if ( $curRevision
+ && $oldRevision
+ && $curRevision->getId() !== $oldRevision->getId()
+ && ( WikiPage::hasDifferencesOutsideMainSlot( $oldRevision, $curRevision )
+ || !$this->isSupportedContentModel( $oldRevision->getContentModel() ) )
+ ) {
+ $this->context->getOutput()->redirect(
+ $this->mTitle->getFullURL(
+ [
+ 'action' => 'mcrrestore',
+ 'restore' => $oldRevision->getId(),
+ ]
+ )
+ );
- if ( $content === false ) {
- $content = $this->getOriginalContent( $user );
+ return false;
}
}
+
+ if ( $content === false ) {
+ $content = $this->getOriginalContent( $user );
+ }
}
return $content;
$out->addHTML( $this->editFormTextTop );
- if ( $this->wasDeletedSinceLastEdit() ) {
- if ( $this->formtype !== 'save' ) {
- $out->wrapWikiMsg( "<div class='error mw-deleted-while-editing'>\n$1\n</div>",
- 'deletedwhileediting' );
- }
+ if ( $this->wasDeletedSinceLastEdit() && $this->formtype !== 'save' ) {
+ $out->wrapWikiMsg( "<div class='error mw-deleted-while-editing'>\n$1\n</div>",
+ 'deletedwhileediting' );
}
// @todo add EditForm plugin interface and use it here!
$this->addExplainConflictHeader( $out );
$this->editRevId = $this->page->getLatest();
} else {
- if ( $this->section != '' && $this->section != 'new' ) {
- if ( !$this->summary && !$this->preview && !$this->diff ) {
- $sectionTitle = self::extractSectionTitle( $this->textbox1 ); // FIXME: use Content object
- if ( $sectionTitle !== false ) {
- $this->summary = "/* $sectionTitle */ ";
- }
+ if ( $this->section != '' && $this->section != 'new' && !$this->summary &&
+ !$this->preview && !$this->diff
+ ) {
+ $sectionTitle = self::extractSectionTitle( $this->textbox1 ); // FIXME: use Content object
+ if ( $sectionTitle !== false ) {
+ $this->summary = "/* $sectionTitle */ ";
}
}
'anonpreviewwarning'
);
}
- } else {
- if ( $this->mTitle->isUserConfigPage() ) {
- # Check the skin exists
- if ( $this->isWrongCaseUserConfigPage() ) {
- $out->wrapWikiMsg(
- "<div class='error' id='mw-userinvalidconfigtitle'>\n$1\n</div>",
- [ 'userinvalidconfigtitle', $this->mTitle->getSkinFromConfigSubpage() ]
- );
- }
- if ( $this->getTitle()->isSubpageOf( $user->getUserPage() ) ) {
- $isUserCssConfig = $this->mTitle->isUserCssConfigPage();
- $isUserJsonConfig = $this->mTitle->isUserJsonConfigPage();
- $isUserJsConfig = $this->mTitle->isUserJsConfigPage();
-
- $warning = $isUserCssConfig
- ? 'usercssispublic'
- : ( $isUserJsonConfig ? 'userjsonispublic' : 'userjsispublic' );
-
- $out->wrapWikiMsg( '<div class="mw-userconfigpublic">$1</div>', $warning );
-
- if ( $this->formtype !== 'preview' ) {
- $config = $this->context->getConfig();
- if ( $isUserCssConfig && $config->get( 'AllowUserCss' ) ) {
- $out->wrapWikiMsg(
- "<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
- [ 'usercssyoucanpreview' ]
- );
- } elseif ( $isUserJsonConfig /* No comparable 'AllowUserJson' */ ) {
- $out->wrapWikiMsg(
- "<div id='mw-userjsonyoucanpreview'>\n$1\n</div>",
- [ 'userjsonyoucanpreview' ]
- );
- } elseif ( $isUserJsConfig && $config->get( 'AllowUserJs' ) ) {
- $out->wrapWikiMsg(
- "<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
- [ 'userjsyoucanpreview' ]
- );
- }
+ } elseif ( $this->mTitle->isUserConfigPage() ) {
+ # Check the skin exists
+ if ( $this->isWrongCaseUserConfigPage() ) {
+ $out->wrapWikiMsg(
+ "<div class='error' id='mw-userinvalidconfigtitle'>\n$1\n</div>",
+ [ 'userinvalidconfigtitle', $this->mTitle->getSkinFromConfigSubpage() ]
+ );
+ }
+ if ( $this->getTitle()->isSubpageOf( $user->getUserPage() ) ) {
+ $isUserCssConfig = $this->mTitle->isUserCssConfigPage();
+ $isUserJsonConfig = $this->mTitle->isUserJsonConfigPage();
+ $isUserJsConfig = $this->mTitle->isUserJsConfigPage();
+
+ $warning = $isUserCssConfig
+ ? 'usercssispublic'
+ : ( $isUserJsonConfig ? 'userjsonispublic' : 'userjsispublic' );
+
+ $out->wrapWikiMsg( '<div class="mw-userconfigpublic">$1</div>', $warning );
+
+ if ( $this->formtype !== 'preview' ) {
+ $config = $this->context->getConfig();
+ if ( $isUserCssConfig && $config->get( 'AllowUserCss' ) ) {
+ $out->wrapWikiMsg(
+ "<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
+ [ 'usercssyoucanpreview' ]
+ );
+ } elseif ( $isUserJsonConfig /* No comparable 'AllowUserJson' */ ) {
+ $out->wrapWikiMsg(
+ "<div id='mw-userjsonyoucanpreview'>\n$1\n</div>",
+ [ 'userjsonyoucanpreview' ]
+ );
+ } elseif ( $isUserJsConfig && $config->get( 'AllowUserJs' ) ) {
+ $out->wrapWikiMsg(
+ "<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
+ [ 'userjsyoucanpreview' ]
+ );
}
}
}
if ( $this->nosummary ) {
return;
}
- } else {
- if ( !$this->mShowSummaryField ) {
- return;
- }
+ } elseif ( !$this->mShowSummaryField ) {
+ return;
}
$labelText = $this->context->msg( $isSubjectPreview ? 'subject' : 'summary' )->parse();
$lang->formatNum( $maxArticleSize )
]
);
- } else {
- if ( !$this->context->msg( 'longpage-hint' )->isDisabled() ) {
- $out->wrapWikiMsg( "<div id='mw-edit-longpage-hint'>\n$1\n</div>",
- [
- 'longpage-hint',
- $lang->formatSize( strlen( $this->textbox1 ) ),
- strlen( $this->textbox1 )
- ]
- );
- }
+ } elseif ( !$this->context->msg( 'longpage-hint' )->isDisabled() ) {
+ $out->wrapWikiMsg( "<div id='mw-edit-longpage-hint'>\n$1\n</div>",
+ [
+ 'longpage-hint',
+ $lang->formatSize( strlen( $this->textbox1 ) ),
+ strlen( $this->textbox1 )
+ ]
+ );
}
}
if ( $integrity === $actualIntegrity ) {
$this->verbose( "... passed integrity check for {$src}\n" );
$this->cacheSet( $key, $data );
+ } elseif ( $this->action === 'make-sri' ) {
+ $this->output( "Integrity for {$src}\n\tintegrity: ${actualIntegrity}\n" );
} else {
- if ( $this->action === 'make-sri' ) {
- $this->output( "Integrity for {$src}\n\tintegrity: ${actualIntegrity}\n" );
- } else {
- throw new Exception( "Integrity check failed for {$src}\n" .
- "\tExpected: {$integrity}\n" .
- "\tActual: {$actualIntegrity}"
- );
- }
+ throw new Exception( "Integrity check failed for {$src}\n" .
+ "\tExpected: {$integrity}\n" .
+ "\tActual: {$actualIntegrity}"
+ );
}
return $data;
}
// to avoid getting in some kind of infinite loop.
break;
}
- if ( $resetGzipEncoding ) {
- if ( $status['name'] == 'ob_gzhandler' ) {
- // Reset the 'Content-Encoding' field set by this handler
- // so we can start fresh.
- header_remove( 'Content-Encoding' );
- break;
- }
+ if ( $resetGzipEncoding && $status['name'] == 'ob_gzhandler' ) {
+ // Reset the 'Content-Encoding' field set by this handler
+ // so we can start fresh.
+ header_remove( 'Content-Encoding' );
+ break;
}
}
}
$attrs = [];
if ( $nonce !== null ) {
$attrs['nonce'] = $nonce;
- } else {
- if ( ContentSecurityPolicy::isNonceRequired( RequestContext::getMain()->getConfig() ) ) {
- wfWarn( "no nonce set on script. CSP will break it" );
- }
+ } elseif ( ContentSecurityPolicy::isNonceRequired( RequestContext::getMain()->getConfig() ) ) {
+ wfWarn( "no nonce set on script. CSP will break it" );
}
if ( preg_match( '/<\/?script/i', $contents ) ) {
$attrs = [ 'src' => $url ];
if ( $nonce !== null ) {
$attrs['nonce'] = $nonce;
- } else {
- if ( ContentSecurityPolicy::isNonceRequired( RequestContext::getMain()->getConfig() ) ) {
- wfWarn( "no nonce set on script. CSP will break it" );
- }
+ } elseif ( ContentSecurityPolicy::isNonceRequired( RequestContext::getMain()->getConfig() ) ) {
+ wfWarn( "no nonce set on script. CSP will break it" );
}
return self::element( 'script', $attrs );
* @return string[] Corresponding grant descriptions
*/
public static function grantNames( array $grants, $lang = null ) {
- if ( $lang !== null ) {
- if ( is_string( $lang ) ) {
- $lang = Language::factory( $lang );
- }
+ if ( $lang !== null && is_string( $lang ) ) {
+ $lang = Language::factory( $lang );
}
$ret = [];
if ( !$ignoreRedirect && ( $target || $page->isRedirect() ) ) {
// Is the target already set by an extension?
$target = $target ?: $page->followRedirect();
- if ( is_string( $target ) ) {
- if ( !$this->config->get( 'DisableHardRedirects' ) ) {
- // we'll need to redirect
- return $target;
- }
+ if ( is_string( $target ) && !$this->config->get( 'DisableHardRedirects' ) ) {
+ // we'll need to redirect
+ return $target;
}
if ( is_object( $target ) ) {
// Rewrite environment to redirected article
// escaped, breaking the replacement and avoiding XSS.
$replacementKeys['$' . ( $n + 1 )] = $marker . ( $n + 1 );
}
- } else {
- if ( $paramType === 'after' ) {
- $replacementKeys[$marker . ( $n + 1 )] = $value;
- }
+ } elseif ( $paramType === 'after' ) {
+ $replacementKeys[$marker . ( $n + 1 )] = $value;
}
}
- $message = strtr( $message, $replacementKeys );
- return $message;
+ return strtr( $message, $replacementKeys );
}
/**
if ( $config->get( 'EnableCanonicalServerLink' ) ) {
if ( $canonicalUrl !== false ) {
$canonicalUrl = wfExpandUrl( $canonicalUrl, PROTO_CANONICAL );
- } else {
- if ( $this->isArticleRelated() ) {
- // This affects all requests where "setArticleRelated" is true. This is
- // typically all requests that show content (query title, curid, oldid, diff),
- // and all wikipage actions (edit, delete, purge, info, history etc.).
- // It does not apply to File pages and Special pages.
- // 'history' and 'info' actions address page metadata rather than the page
- // content itself, so they may not be canonicalized to the view page url.
- // TODO: this ought to be better encapsulated in the Action class.
- $action = Action::getActionName( $this->getContext() );
- if ( in_array( $action, [ 'history', 'info' ] ) ) {
- $query = "action={$action}";
- } else {
- $query = '';
- }
- $canonicalUrl = $this->getTitle()->getCanonicalURL( $query );
+ } elseif ( $this->isArticleRelated() ) {
+ // This affects all requests where "setArticleRelated" is true. This is
+ // typically all requests that show content (query title, curid, oldid, diff),
+ // and all wikipage actions (edit, delete, purge, info, history etc.).
+ // It does not apply to File pages and Special pages.
+ // 'history' and 'info' actions address page metadata rather than the page
+ // content itself, so they may not be canonicalized to the view page url.
+ // TODO: this ought to be better encapsulated in the Action class.
+ $action = Action::getActionName( $this->getContext() );
+ if ( in_array( $action, [ 'history', 'info' ] ) ) {
+ $query = "action={$action}";
} else {
- $reqUrl = $this->getRequest()->getRequestURL();
- $canonicalUrl = wfExpandUrl( $reqUrl, PROTO_CANONICAL );
+ $query = '';
}
+ $canonicalUrl = $this->getTitle()->getCanonicalURL( $query );
+ } else {
+ $reqUrl = $this->getRequest()->getRequestURL();
+ $canonicalUrl = wfExpandUrl( $reqUrl, PROTO_CANONICAL );
}
}
if ( $canonicalUrl !== false ) {
* @return string HTML fragment
*/
protected function styleLink( $style, array $options ) {
- if ( isset( $options['dir'] ) ) {
- if ( $this->getLanguage()->getDir() != $options['dir'] ) {
- return '';
- }
+ if ( isset( $options['dir'] ) && $this->getLanguage()->getDir() != $options['dir'] ) {
+ return '';
}
if ( isset( $options['media'] ) ) {
if ( $propertyValue === false ) {
$queryIDs[] = $pageID;
break;
+ } elseif ( $gotArray ) {
+ $values[$pageID][$propertyName] = $propertyValue;
} else {
- if ( $gotArray ) {
- $values[$pageID][$propertyName] = $propertyValue;
- } else {
- $values[$pageID] = $propertyValue;
- }
+ $values[$pageID] = $propertyValue;
}
}
}
// Loop over our options and convert any single value $# restrictions
// into an array so we only have to do in_array tests.
foreach ( $options as $optionName => $optionData ) {
- if ( preg_match( '/^\$\d+$/u', $optionName ) ) {
- if ( !is_array( $optionData ) ) {
- $options[$optionName] = [ $optionData ];
- }
+ if ( preg_match( '/^\$\d+$/u', $optionName ) && !is_array( $optionData ) ) {
+ $options[$optionName] = [ $optionData ];
}
}
// Hook can determine default model
$title = Title::newFromLinkTarget( $page );
- if ( !Hooks::run( 'ContentHandlerDefaultModelFor', [ $title, &$model ] ) ) {
- if ( !is_null( $model ) ) {
- return $model;
- }
+ if ( !Hooks::run( 'ContentHandlerDefaultModelFor', [ $title, &$model ] ) && !is_null( $model ) ) {
+ return $model;
}
// Could this page contain code based on the title?
}
// if we have a content object, use it to set the model and type
- if ( !empty( $fields['content'] ) ) {
- if ( !( $fields['content'] instanceof Content ) && !is_array( $fields['content'] ) ) {
- throw new MWException(
- 'content field must contain a Content object or an array of Content objects.'
- );
- }
+ if ( !empty( $fields['content'] ) && !( $fields['content'] instanceof Content )
+ && !is_array( $fields['content'] )
+ ) {
+ throw new MWException(
+ 'content field must contain a Content object or an array of Content objects.'
+ );
}
if ( !empty( $fields['text_id'] ) ) {
$linkCache->clearLink( $this );
$this->mArticleID = $linkCache->addLinkObj( $this );
$linkCache->forUpdate( $oldUpdate );
- } else {
- if ( $this->mArticleID == -1 ) {
- $this->mArticleID = $linkCache->addLinkObj( $this );
- }
+ } elseif ( $this->mArticleID == -1 ) {
+ $this->mArticleID = $linkCache->addLinkObj( $this );
}
return $this->mArticleID;
}
}
if ( is_null( $contents ) ) {
$out .= '>';
+ } elseif ( $allowShortTag && $contents === '' ) {
+ $out .= ' />';
} else {
- if ( $allowShortTag && $contents === '' ) {
- $out .= ' />';
- } else {
- $out .= '>' . htmlspecialchars( $contents, ENT_NOQUOTES ) . "</$element>";
- }
+ $out .= '>' . htmlspecialchars( $contents, ENT_NOQUOTES ) . "</$element>";
}
return $out;
}
$link = $this->link( $user );
if ( $user->isAnon() ) {
return $this->msg( 'anonuser' )->rawParams( $link )->parse();
+ } elseif ( $this->canShowRealUserName() && $user->getRealName() ) {
+ return $link;
} else {
- if ( $this->canShowRealUserName() && $user->getRealName() ) {
- return $link;
- } else {
- return $this->msg( 'siteuser' )->rawParams( $link )->params( $user->getName() )->escaped();
- }
+ return $this->msg( 'siteuser' )->rawParams( $link )->params( $user->getName() )->escaped();
}
}
foreach ( [ 'from', 'to' ] as $prefix ) {
if ( $params["{$prefix}rev"] !== null ) {
$rev = $this->getRevisionById( $params["{$prefix}rev"] );
- if ( $rev ) {
- if ( $rev->hasSlot( $role ) ) {
- return $rev->getSlot( $role, RevisionRecord::RAW )->getModel();
- }
+ if ( $rev && $rev->hasSlot( $role ) ) {
+ return $rev->getSlot( $role, RevisionRecord::RAW )->getModel();
}
}
}
$arr = &$submodules;
try {
$submod = $module->getModuleFromPath( $m );
- if ( $submod ) {
- if ( $submod->isDeprecated() ) {
- $arr = &$deprecatedSubmodules;
- $attrs['class'] = 'apihelp-deprecated-value';
- }
+ if ( $submod && $submod->isDeprecated() ) {
+ $arr = &$deprecatedSubmodules;
+ $attrs['class'] = 'apihelp-deprecated-value';
}
} catch ( ApiUsageException $ex ) {
// Ignore
. $this->msg( 'api-usage-mailinglist-ref' )->inLanguage( $formatter->getLanguage() )->text()
)
);
- } else {
- if ( $config->get( 'ShowExceptionDetails' ) ) {
- $result->addContentValue(
- $path,
- 'trace',
- $this->msg( 'api-exception-trace',
- get_class( $e ),
- $e->getFile(),
- $e->getLine(),
- MWExceptionHandler::getRedactedTraceAsString( $e )
- )->inLanguage( $formatter->getLanguage() )->text()
- );
- }
+ } elseif ( $config->get( 'ShowExceptionDetails' ) ) {
+ $result->addContentValue(
+ $path,
+ 'trace',
+ $this->msg( 'api-exception-trace',
+ get_class( $e ),
+ $e->getFile(),
+ $e->getLine(),
+ MWExceptionHandler::getRedactedTraceAsString( $e )
+ )->inLanguage( $formatter->getLanguage() )->text()
+ );
}
// Add the id and such
$data[$toPageId],
$this->mGeneratorData[$fromNs][$fromDBkey]
);
- if ( $result instanceof ApiResult ) {
- if ( !$result->addValue( $path, $toPageId, $data[$toPageId], ApiResult::OVERRIDE ) ) {
- return false;
- }
+ if ( $result instanceof ApiResult &&
+ !$result->addValue( $path, $toPageId, $data[$toPageId], ApiResult::OVERRIDE )
+ ) {
+ return false;
}
}
}
*/
protected function addTables( $tables, $alias = null ) {
if ( is_array( $tables ) ) {
- if ( !is_null( $alias ) ) {
+ if ( $alias !== null ) {
ApiBase::dieDebug( __METHOD__, 'Multiple table aliases not supported' );
}
$this->tables = array_merge( $this->tables, $tables );
+ } elseif ( $alias !== null ) {
+ $this->tables[$alias] = $tables;
} else {
- if ( !is_null( $alias ) ) {
- $this->tables[$alias] = $tables;
- } else {
- $this->tables[] = $tables;
- }
+ $this->tables[] = $tables;
}
}
// Don't set $scale['width']; this signals mergeThumbParams() to fill it with the image's width
$scale = [];
$scale['height'] = $params['urlheight'];
+ } elseif ( $params['urlparam'] ) {
+ // Audio files might not have a width/height.
+ $scale = [];
} else {
- if ( $params['urlparam'] ) {
- // Audio files might not have a width/height.
- $scale = [];
- } else {
- $scale = null;
- }
+ $scale = null;
}
return $scale;
}
}
- if ( $this->fld_varianttitles ) {
- if ( isset( $this->variantTitles[$pageid] ) ) {
- $pageInfo['varianttitles'] = $this->variantTitles[$pageid];
- }
+ if ( $this->fld_varianttitles && isset( $this->variantTitles[$pageid] ) ) {
+ $pageInfo['varianttitles'] = $this->variantTitles[$pageid];
}
if ( $this->params['testactions'] ) {
$vals['realname'] = $user->getRealName();
}
- if ( $user->isAllowed( 'viewmyprivateinfo' ) ) {
- if ( isset( $this->prop['email'] ) ) {
- $vals['email'] = $user->getEmail();
- $auth = $user->getEmailAuthenticationTimestamp();
- if ( !is_null( $auth ) ) {
- $vals['emailauthenticated'] = wfTimestamp( TS_ISO_8601, $auth );
- }
+ if ( $user->isAllowed( 'viewmyprivateinfo' ) && isset( $this->prop['email'] ) ) {
+ $vals['email'] = $user->getEmail();
+ $auth = $user->getEmailAuthenticationTimestamp();
+ if ( $auth !== null ) {
+ $vals['emailauthenticated'] = wfTimestamp( TS_ISO_8601, $auth );
}
}
$this->fld_loginfo = isset( $prop['loginfo'] );
$this->fld_tags = isset( $prop['tags'] );
- if ( $this->fld_patrol ) {
- if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
- $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'patrol' );
- }
+ if ( $this->fld_patrol && !$user->useRCPatrol() && !$user->useNPPatrol() ) {
+ $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'patrol' );
}
if ( $this->fld_comment || $this->fld_parsedcomment ) {
$startFrom = [ $recentChangeInfo['rc_timestamp'], $recentChangeInfo['rc_id'] ];
break;
}
+ } elseif ( $params['allrev'] ) {
+ $ids[] = (int)$recentChangeInfo['rc_this_oldid'];
} else {
- if ( $params['allrev'] ) {
- $ids[] = (int)$recentChangeInfo['rc_this_oldid'];
- } else {
- $ids[] = (int)$recentChangeInfo['rc_cur_id'];
- }
+ $ids[] = (int)$recentChangeInfo['rc_cur_id'];
}
}
$id = $req->getUniqueId();
// If a required request if from a Primary, mark it as "primary-required" instead
- if ( $isPrimary ) {
- if ( $req->required ) {
- $req->required = AuthenticationRequest::PRIMARY_REQUIRED;
- }
+ if ( $isPrimary && $req->required ) {
+ $req->required = AuthenticationRequest::PRIMARY_REQUIRED;
}
if (
}
$req = AuthenticationRequest::getRequestByClass( $reqs, PasswordAuthenticationRequest::class );
- if ( $req ) {
- if ( $req->username !== null && $req->password !== null ) {
- // Nothing we can do besides claim it, because the user isn't in
- // the DB yet
- if ( $req->username !== $user->getName() ) {
- $req = clone $req;
- $req->username = $user->getName();
- }
- $ret = AuthenticationResponse::newPass( $req->username );
- $ret->createRequest = $req;
- return $ret;
+ if ( $req && $req->username !== null && $req->password !== null ) {
+ // Nothing we can do besides claim it, because the user isn't in
+ // the DB yet
+ if ( $req->username !== $user->getName() ) {
+ $req = clone $req;
+ $req->username = $user->getName();
}
+ $ret = AuthenticationResponse::newPass( $req->username );
+ $ret->createRequest = $req;
+ return $ret;
}
return AuthenticationResponse::newAbstain();
}
$req = AuthenticationRequest::getRequestByClass(
$reqs, TemporaryPasswordAuthenticationRequest::class
);
- if ( $req ) {
- if ( $req->username !== null && $req->password !== null ) {
- // Nothing we can do yet, because the user isn't in the DB yet
- if ( $req->username !== $user->getName() ) {
- $req = clone $req;
- $req->username = $user->getName();
- }
-
- if ( $req->mailpassword ) {
- // prevent EmailNotificationSecondaryAuthenticationProvider from sending another mail
- $this->manager->setAuthenticationSessionData( 'no-email', true );
- }
+ if ( $req && $req->username !== null && $req->password !== null ) {
+ // Nothing we can do yet, because the user isn't in the DB yet
+ if ( $req->username !== $user->getName() ) {
+ $req = clone $req;
+ $req->username = $user->getName();
+ }
- $ret = AuthenticationResponse::newPass( $req->username );
- $ret->createRequest = $req;
- return $ret;
+ if ( $req->mailpassword ) {
+ // prevent EmailNotificationSecondaryAuthenticationProvider from sending another mail
+ $this->manager->setAuthenticationSessionData( 'no-email', true );
}
+
+ $ret = AuthenticationResponse::newPass( $req->username );
+ $ret->createRequest = $req;
+ return $ret;
}
return AuthenticationResponse::newAbstain();
}
} else {
$value = array_shift( $this->cachedChunks );
}
+ } elseif ( array_key_exists( $key, $this->cachedChunks ) ) {
+ $value = $this->cachedChunks[$key];
+ unset( $this->cachedChunks[$key] );
} else {
- if ( array_key_exists( $key, $this->cachedChunks ) ) {
- $value = $this->cachedChunks[$key];
- unset( $this->cachedChunks[$key] );
- } else {
- wfWarn( "There is no item with key '$key' in this->cachedChunks in " . __METHOD__ );
- }
+ wfWarn( "There is no item with key '$key' in this->cachedChunks in " . __METHOD__ );
}
} else {
if ( !is_array( $args ) ) {
return false;
}
- if ( $mode === self::MODE_NORMAL ) {
- if ( $user->getNewtalk() ) {
- return false;
- }
+ if ( ( $mode === self::MODE_NORMAL ) && $user->getNewtalk() ) {
+ return false;
}
// Allow extensions to disable caching
}
// gzip output to buffer as needed and set headers...
- if ( $this->useGzip() ) {
- // @todo Ugly wfClientAcceptsGzip() function - use context!
- if ( wfClientAcceptsGzip() ) {
- header( 'Content-Encoding: gzip' );
+ // @todo Ugly wfClientAcceptsGzip() function - use context!
+ if ( $this->useGzip() && wfClientAcceptsGzip() ) {
+ header( 'Content-Encoding: gzip' );
- return $compressed;
- } else {
- return $text;
- }
- } else {
- return $text;
+ return $compressed;
}
+
+ return $text;
}
/**
if ( $this->timestamp === false ) {
# Still nonexistent
return false;
- } else {
- # Deleted
- wfDebug( "Dependency triggered: {$this->filename} deleted.\n" );
-
- return true;
}
- } else {
- if ( $lastmod > $this->timestamp ) {
- # Modified or created
- wfDebug( "Dependency triggered: {$this->filename} changed.\n" );
- return true;
- } else {
- # Not modified
- return false;
- }
+ # Deleted
+ wfDebug( "Dependency triggered: {$this->filename} deleted.\n" );
+
+ return true;
}
+
+ if ( $lastmod > $this->timestamp ) {
+ # Modified or created
+ wfDebug( "Dependency triggered: {$this->filename} changed.\n" );
+
+ return true;
+ }
+
+ # Not modified
+ return false;
}
}
}
public function startWrite( $code ) {
- if ( !file_exists( $this->directory ) ) {
- if ( !wfMkdirParents( $this->directory, null, __METHOD__ ) ) {
- throw new MWException( "Unable to create the localisation store " .
- "directory \"{$this->directory}\"" );
- }
+ if ( !file_exists( $this->directory ) && !wfMkdirParents( $this->directory, null, __METHOD__ ) ) {
+ throw new MWException( "Unable to create the localisation store " .
+ "directory \"{$this->directory}\"" );
}
// Close reader to stop permission errors on write
}
public function startWrite( $code ) {
- if ( !file_exists( $this->directory ) ) {
- if ( !wfMkdirParents( $this->directory, null, __METHOD__ ) ) {
- throw new MWException( "Unable to create the localisation store " .
- "directory \"{$this->directory}\"" );
- }
+ if ( !file_exists( $this->directory ) && !wfMkdirParents( $this->directory, null, __METHOD__ ) ) {
+ throw new MWException( "Unable to create the localisation store " .
+ "directory \"{$this->directory}\"" );
}
$this->currentLang = $code;
foreach ( $digits as $digit ) {
$letters[] = $this->digitTransformLanguage->formatNum( $digit, true );
}
+ } elseif ( $this->locale === 'root' ) {
+ $letters = require "$IP/includes/collation/data/first-letters-root.php";
} else {
- if ( $this->locale === 'root' ) {
- $letters = require "$IP/includes/collation/data/first-letters-root.php";
- } else {
- // FIXME: Is this still used?
- $letters = wfGetPrecompiledData( "first-letters-{$this->locale}.ser" );
- if ( $letters === false ) {
- throw new MWException( "MediaWiki does not support ICU locale " .
- "\"{$this->locale}\"" );
- }
+ // FIXME: Is this still used?
+ $letters = wfGetPrecompiledData( "first-letters-{$this->locale}.ser" );
+ if ( $letters === false ) {
+ throw new MWException( "MediaWiki does not support ICU locale " .
+ "\"{$this->locale}\"" );
}
}
self::getShowBacktraceError( $e );
}
$message .= "\n";
+ } elseif ( $wgShowExceptionDetails ) {
+ $message = MWExceptionHandler::getLogMessage( $e ) .
+ "\nBacktrace:\n" .
+ MWExceptionHandler::getRedactedTraceAsString( $e ) . "\n";
} else {
- if ( $wgShowExceptionDetails ) {
- $message = MWExceptionHandler::getLogMessage( $e ) .
- "\nBacktrace:\n" .
- MWExceptionHandler::getRedactedTraceAsString( $e ) . "\n";
- } else {
- $message = MWExceptionHandler::getPublicLogMessage( $e );
- }
+ $message = MWExceptionHandler::getPublicLogMessage( $e );
}
echo nl2br( htmlspecialchars( $message ) ) . "\n";
}
if ( !$knownThumbUrls ) {
/* No knownThumbUrls for this file */
$knownThumbUrls = [];
- } else {
- if ( isset( $knownThumbUrls[$sizekey] ) ) {
- wfDebug( __METHOD__ . ': Got thumburl from local cache: ' .
- "{$knownThumbUrls[$sizekey]} \n" );
+ } elseif ( isset( $knownThumbUrls[$sizekey] ) ) {
+ wfDebug( __METHOD__ . ': Got thumburl from local cache: ' .
+ "{$knownThumbUrls[$sizekey]} \n" );
- return $knownThumbUrls[$sizekey];
- }
- /* This size is not yet known */
+ return $knownThumbUrls[$sizekey];
}
$metadata = null;
// one would not expect it to be animated
// so true.
return true;
- } else {
- if ( $this->allowInlineDisplay()
- && $handler->isAnimatedImage( $this )
- && !$handler->canAnimateThumbnail( $this )
- ) {
- // Image is animated, but thumbnail isn't.
- // This is unexpected to the user.
- return false;
- } else {
- // Image is not animated, so one would
- // not expect thumb to be
- return true;
- }
}
+
+ return !$this->allowInlineDisplay()
+ // Image is not animated, so one would
+ // not expect thumb to be
+ || !$handler->isAnimatedImage( $this )
+ // Image is animated, but thumbnail isn't.
+ // This is unexpected to the user.
+ || $handler->canAnimateThumbnail( $this );
}
/**
$dstRel = $this->getArchiveRel( $archiveName );
$status = $this->publishTo( $srcPath, $dstRel );
- if ( $status->isGood() ) {
- if ( !$this->recordOldUpload( $srcPath, $archiveName, $timestamp, $comment, $user ) ) {
- $status->fatal( 'filenotfound', $srcPath );
- }
+ if ( $status->isGood() &&
+ !$this->recordOldUpload( $srcPath, $archiveName, $timestamp, $comment, $user )
+ ) {
+ $status->fatal( 'filenotfound', $srcPath );
}
$this->unlock();
// $value is a string, because HTMLForm fields store their values as strings
$namespaces = explode( "\n", $value );
- if ( isset( $this->mParams['max'] ) ) {
- if ( count( $namespaces ) > $this->mParams['max'] ) {
- return $this->msg( 'htmlform-int-toohigh', $this->mParams['max'] );
- }
+ if ( isset( $this->mParams['max'] ) && ( count( $namespaces ) > $this->mParams['max'] ) ) {
+ return $this->msg( 'htmlform-int-toohigh', $this->mParams['max'] );
}
foreach ( $namespaces as $namespace ) {
// $value is a string, because HTMLForm fields store their values as strings
$titlesArray = explode( "\n", $value );
- if ( isset( $this->mParams['max'] ) ) {
- if ( count( $titlesArray ) > $this->mParams['max'] ) {
- return $this->msg( 'htmlform-int-toohigh', $this->mParams['max'] );
- }
+ if ( isset( $this->mParams['max'] ) && ( count( $titlesArray ) > $this->mParams['max'] ) ) {
+ return $this->msg( 'htmlform-int-toohigh', $this->mParams['max'] );
}
foreach ( $titlesArray as $title ) {
if ( !$title || $title->isExternal() ) {
$status->fatal( 'import-rootpage-invalid' );
+ } elseif ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+ $displayNSText = $title->getNamespace() == NS_MAIN
+ ? wfMessage( 'blanknamespace' )->text()
+ : MediaWikiServices::getInstance()->getContentLanguage()->
+ getNsText( $title->getNamespace() );
+ $status->fatal( 'import-rootpage-nosubpage', $displayNSText );
} else {
- if ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
- $displayNSText = $title->getNamespace() == NS_MAIN
- ? wfMessage( 'blanknamespace' )->text()
- : MediaWikiServices::getInstance()->getContentLanguage()->
- getNsText( $title->getNamespace() );
- $status->fatal( 'import-rootpage-nosubpage', $displayNSText );
- } else {
- // set namespace to 'all', so the namespace check in processTitle() can pass
- $this->setTargetNamespace( null );
- $this->setImportTitleFactory( new SubpageImportTitleFactory( $title ) );
- }
+ // set namespace to 'all', so the namespace check in processTitle() can pass
+ $this->setTargetNamespace( null );
+ $this->setImportTitleFactory( new SubpageImportTitleFactory( $title ) );
}
}
return $status;
}
// Recursively search each member of the group to see if the target
// is a member of it, up to the given maximum depth.
- if ( $maxDepth > 0 ) {
- if ( $this->isRoleMember( $conn, $targetMember, $row->member, $maxDepth - 1 ) ) {
- // Found member of member
- return true;
- }
+ if ( $maxDepth > 0 &&
+ $this->isRoleMember( $conn, $targetMember, $row->member, $maxDepth - 1 )
+ ) {
+ // Found member of member
+ return true;
}
}
public function addPgExtIndex( $table, $index, $type ) {
if ( $this->db->indexExists( $table, $index ) ) {
$this->output( "...index '$index' on table '$table' already exists\n" );
+ } elseif ( preg_match( '/^\(/', $type ) ) {
+ $this->output( "Creating index '$index' on table '$table'\n" );
+ $this->db->query( "CREATE INDEX $index ON $table $type" );
} else {
- if ( preg_match( '/^\(/', $type ) ) {
- $this->output( "Creating index '$index' on table '$table'\n" );
- $this->db->query( "CREATE INDEX $index ON $table $type" );
- } else {
- $this->applyPatch( $type, true, "Creating index '$index' on table '$table'" );
- }
+ $this->applyPatch( $type, true, "Creating index '$index' on table '$table'" );
}
}
if ( !is_writable( $file ) ) {
return Status::newFatal( 'config-sqlite-readonly', $file );
}
- } else {
- if ( file_put_contents( $file, '' ) === false ) {
- return Status::newFatal( 'config-sqlite-cant-create-db', $file );
- }
+ } elseif ( file_put_contents( $file, '' ) === false ) {
+ return Status::newFatal( 'config-sqlite-cant-create-db', $file );
}
return Status::newGood();
if ( $value === null ) {
// Checkbox?
$this->setVar( $name, false );
+ } elseif ( stripos( $name, 'password' ) !== false ) {
+ $this->setPassword( $name, $value );
} else {
- if ( stripos( $name, 'password' ) !== false ) {
- $this->setPassword( $name, $value );
- } else {
- $this->setVar( $name, $value );
- }
+ $this->setVar( $name, $value );
}
}
*/
public function execute() {
$r = $this->parent->request;
- if ( $r->wasPosted() ) {
- if ( $this->submit() ) {
- return 'continue';
- }
+ if ( $r->wasPosted() && $this->submit() ) {
+ return 'continue';
}
$this->startForm();
$this->submitSkins();
return 'skip';
}
- if ( $this->parent->request->wasPosted() ) {
- if ( $this->submit() ) {
- return 'continue';
- }
+ if ( $this->parent->request->wasPosted() && $this->submit() ) {
+ return 'continue';
}
$emailwrapperStyle = $this->getVar( 'wgEnableEmail' ) ? '' : 'display: none';
* @return string
*/
public function execute() {
- if ( $this->parent->request->wasPosted() ) {
- if ( $this->getVar( '_Environment' ) ) {
- return 'continue';
- }
+ if ( $this->parent->request->wasPosted() && $this->getVar( '_Environment' ) ) {
+ return 'continue';
}
$this->parent->output->addWikiTextAsInterface( wfMessage( 'config-welcome' )->plain() );
$status = $this->parent->doEnvironmentChecks();
}
} while ( $mrc == CURLM_CALL_MULTI_PERFORM );
// Wait (if possible) for available work...
- if ( $active > 0 && $mrc == CURLM_OK ) {
- if ( curl_multi_select( $chm, $selectTimeout ) == -1 ) {
- // PHP bug 63411; https://curl.haxx.se/libcurl/c/curl_multi_fdset.html
- usleep( 5000 ); // 5ms
- }
+ if ( $active > 0 && $mrc == CURLM_OK && curl_multi_select( $chm, $selectTimeout ) == -1 ) {
+ // PHP bug 63411; https://curl.haxx.se/libcurl/c/curl_multi_fdset.html
+ usleep( 5000 ); // 5ms
}
} while ( $active > 0 && $mrc == CURLM_OK );
}
$status->fatal( 'backend-fail-synced', $path );
continue;
}
- if ( $this->syncChecks & self::CHECK_SIZE ) {
- if ( $cStat['size'] != $mStat['size'] ) { // wrong size
- $status->fatal( 'backend-fail-synced', $path );
- continue;
- }
+ if ( ( $this->syncChecks & self::CHECK_SIZE )
+ && $cStat['size'] != $mStat['size']
+ ) { // wrong size
+ $status->fatal( 'backend-fail-synced', $path );
+ continue;
}
if ( $this->syncChecks & self::CHECK_TIME ) {
$mTs = wfTimestamp( TS_UNIX, $mStat['mtime'] );
continue;
}
}
- if ( $this->syncChecks & self::CHECK_SHA1 ) {
- if ( $cBackend->getFileSha1Base36( $cParams ) !== $mSha1 ) { // wrong SHA1
- $status->fatal( 'backend-fail-synced', $path );
- continue;
- }
- }
- } else { // file is not in master
- if ( $cStat ) { // file should not exist
+ if ( ( $this->syncChecks & self::CHECK_SHA1 ) && $cBackend->getFileSha1Base36( $cParams ) !== $mSha1 ) { // wrong SHA1
$status->fatal( 'backend-fail-synced', $path );
+ continue;
}
+ } elseif ( $cStat ) { // file is not in master; file should not exist
+ $status->fatal( 'backend-fail-synced', $path );
}
}
}
$callbackReturn = false;
}
- if ( $checkIfSafe && isset( $parsedDTD['internal'] ) ) {
- if ( !$this->checkDTDIsSafe( $parsedDTD['internal'] ) ) {
- $this->wellFormed = false;
- }
+ if ( $checkIfSafe && isset( $parsedDTD['internal'] ) &&
+ !$this->checkDTDIsSafe( $parsedDTD['internal'] )
+ ) {
+ $this->wellFormed = false;
}
}
[ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
);
// Case C: medium length request with medium replication lag
+ } elseif ( $lockTSE >= 0 ) {
+ // Store value as *almost* stale to avoid cache and mutex stampedes
+ $logicalTTL = self::TTL_SECOND;
+ $this->logger->info(
+ 'Lowered set() TTL for {cachekey} due to high read lag.',
+ [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
+ );
} else {
- if ( $lockTSE >= 0 ) {
- // Store value as *almost* stale to avoid cache and mutex stampedes
- $logicalTTL = self::TTL_SECOND;
- $this->logger->info(
- 'Lowered set() TTL for {cachekey} due to high read lag.',
- [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
- );
- } else {
- $this->logger->info(
- 'Rejected set() for {cachekey} due to high read lag.',
- [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
- );
+ $this->logger->info(
+ 'Rejected set() for {cachekey} due to high read lag.',
+ [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
+ );
- return true; // no-op the write for being unsafe
- }
+ return true; // no-op the write for being unsafe
}
}
$possibleDrivers = $builtinTypes[$dbType];
if ( is_string( $possibleDrivers ) ) {
$class = $possibleDrivers;
+ } elseif ( (string)$driver !== '' ) {
+ if ( !isset( $possibleDrivers[$driver] ) ) {
+ throw new InvalidArgumentException( __METHOD__ .
+ " type '$dbType' does not support driver '{$driver}'" );
+ }
+
+ $class = $possibleDrivers[$driver];
} else {
- if ( (string)$driver !== '' ) {
- if ( !isset( $possibleDrivers[$driver] ) ) {
- throw new InvalidArgumentException( __METHOD__ .
- " type '$dbType' does not support driver '{$driver}'" );
- } else {
- $class = $possibleDrivers[$driver];
- }
- } else {
- foreach ( $possibleDrivers as $posDriver => $possibleClass ) {
- if ( extension_loaded( $posDriver ) ) {
- $class = $possibleClass;
- break;
- }
+ foreach ( $possibleDrivers as $posDriver => $possibleClass ) {
+ if ( extension_loaded( $posDriver ) ) {
+ $class = $possibleClass;
+ break;
}
}
}
public function getLBInfo( $name = null ) {
if ( is_null( $name ) ) {
return $this->lbInfo;
- } else {
- if ( array_key_exists( $name, $this->lbInfo ) ) {
- return $this->lbInfo[$name];
- } else {
- return null;
- }
}
+
+ if ( array_key_exists( $name, $this->lbInfo ) ) {
+ return $this->lbInfo[$name];
+ }
+
+ return null;
}
public function setLBInfo( $name, $value = null ) {
"$fname: Flushing an explicit transaction, getting out of sync."
);
}
- } else {
- if ( !$this->trxLevel ) {
- $this->queryLogger->error(
- "$fname: No transaction to commit, something got out of sync." );
- return; // nothing to do
- } elseif ( $this->trxAutomatic ) {
- throw new DBUnexpectedError(
- $this,
- "$fname: Expected mass commit of all peer transactions (DBO_TRX set)."
- );
- }
+ } elseif ( !$this->trxLevel ) {
+ $this->queryLogger->error(
+ "$fname: No transaction to commit, something got out of sync." );
+ return; // nothing to do
+ } elseif ( $this->trxAutomatic ) {
+ throw new DBUnexpectedError(
+ $this,
+ "$fname: Expected mass commit of all peer transactions (DBO_TRX set)."
+ );
}
$this->assertHasConnectionHandle();
final public function rollback( $fname = __METHOD__, $flush = '' ) {
$trxActive = $this->trxLevel;
- if ( $flush !== self::FLUSHING_INTERNAL && $flush !== self::FLUSHING_ALL_PEERS ) {
- if ( $this->getFlag( self::DBO_TRX ) ) {
- throw new DBUnexpectedError(
- $this,
- "$fname: Expected mass rollback of all peer transactions (DBO_TRX set)."
- );
- }
+ if ( $flush !== self::FLUSHING_INTERNAL
+ && $flush !== self::FLUSHING_ALL_PEERS
+ && $this->getFlag( self::DBO_TRX )
+ ) {
+ throw new DBUnexpectedError(
+ $this,
+ "$fname: Expected mass rollback of all peer transactions (DBO_TRX set)."
+ );
}
if ( $trxActive ) {
$this->waitForPos = $pos;
// If a generic reader connection was already established, then wait now
$i = $this->readIndex;
- if ( $i > 0 ) {
- if ( !$this->doWait( $i ) ) {
- $this->laggedReplicaMode = true;
- }
+ if ( ( $i > 0 ) && !$this->doWait( $i ) ) {
+ $this->laggedReplicaMode = true;
}
} finally {
// Restore the older position if it was higher since this is used for lag-protection
return false;
}
- if ( $this->password !== null ) {
- if ( !$conn->auth( $this->password ) ) {
- $logger->error(
- 'Authentication error connecting to "{redis_server}"',
- [ 'redis_server' => $server ]
- );
- }
+ if ( ( $this->password !== null ) && !$conn->auth( $this->password ) ) {
+ $logger->error(
+ 'Authentication error connecting to "{redis_server}"',
+ [ 'redis_server' => $server ]
+ );
}
} catch ( RedisException $e ) {
$this->downServers[$server] = time() + self::SERVER_DOWN_TTL;
* @return bool Success
*/
public function reauthenticateConnection( $server, Redis $conn ) {
- if ( $this->password !== null ) {
- if ( !$conn->auth( $this->password ) ) {
- $this->logger->error(
- 'Authentication error connecting to "{redis_server}"',
- [ 'redis_server' => $server ]
- );
+ if ( $this->password !== null && !$conn->auth( $this->password ) ) {
+ $this->logger->error(
+ 'Authentication error connecting to "{redis_server}"',
+ [ 'redis_server' => $server ]
+ );
- return false;
- }
+ return false;
}
return true;
&& $watchingUser->getId() != $userTalkId
&& !in_array( $watchingUser->getName(), $wgUsersNotifiedOnAllChanges )
&& !( $wgBlockDisablesLogin && $watchingUser->isBlocked() )
+ && Hooks::run( 'SendWatchlistEmailNotification', [ $watchingUser, $title, $this ] )
) {
- if ( Hooks::run( 'SendWatchlistEmailNotification', [ $watchingUser, $title, $this ] ) ) {
- $this->compose( $watchingUser, self::WATCHLIST );
- }
+ $this->compose( $watchingUser, self::WATCHLIST );
}
}
}
}
$im->setImageDepth( 8 );
- if ( $rotation ) {
- if ( !$im->rotateImage( new ImagickPixel( 'white' ), 360 - $rotation ) ) {
- return $this->getMediaTransformError( $params, "Error rotating $rotation degrees" );
- }
+ if ( $rotation && !$im->rotateImage( new ImagickPixel( 'white' ), 360 - $rotation ) ) {
+ return $this->getMediaTransformError( $params, "Error rotating $rotation degrees" );
}
if ( $this->isAnimatedImage( $image ) ) {
// Do some special casing for multilingual values.
// Don't discard translations if also as a simple value.
foreach ( $this->metadata[$type] as $itemName => $item ) {
- if ( is_array( $item ) && isset( $item['_type'] ) && $item['_type'] === 'lang' ) {
- if ( isset( $temp[$itemName] ) && !is_array( $temp[$itemName] ) ) {
- $default = $temp[$itemName];
- $temp[$itemName] = $item;
- $temp[$itemName]['x-default'] = $default;
- unset( $this->metadata[$type][$itemName] );
- }
+ if ( is_array( $item ) && isset( $item['_type'] ) && $item['_type'] === 'lang' &&
+ isset( $temp[$itemName] ) && !is_array( $temp[$itemName] )
+ ) {
+ $default = $temp[$itemName];
+ $temp[$itemName] = $item;
+ $temp[$itemName]['x-default'] = $default;
+ unset( $this->metadata[$type][$itemName] );
}
}
$params['physicalWidth'] = $wgSVGMaxSize;
$params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight, $wgSVGMaxSize );
}
- } else {
- if ( $params['physicalHeight'] > $wgSVGMaxSize ) {
- $srcWidth = $image->getWidth( $params['page'] );
- $srcHeight = $image->getHeight( $params['page'] );
- $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize );
- $params['physicalHeight'] = $wgSVGMaxSize;
- }
+ } elseif ( $params['physicalHeight'] > $wgSVGMaxSize ) {
+ $srcWidth = $image->getWidth( $params['page'] );
+ $srcHeight = $image->getHeight( $params['page'] );
+ $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize );
+ $params['physicalHeight'] = $wgSVGMaxSize;
}
// To prevent the proliferation of thumbnails in languages not present in SVGs, unless
// explicitly forced by user.
- if ( isset( $params['targetlang'] ) ) {
- if ( !$image->getMatchedLanguage( $params['targetlang'] ) ) {
- unset( $params['targetlang'] );
- }
+ if ( isset( $params['targetlang'] ) && !$image->getMatchedLanguage( $params['targetlang'] ) ) {
+ unset( $params['targetlang'] );
}
return $params;
* [[MediaWiki:Talkpagetext]]. For Article::view().
*/
public function showNamespaceHeader() {
- if ( $this->getTitle()->isTalkPage() ) {
- if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
- $this->getContext()->getOutput()->wrapWikiMsg(
- "<div class=\"mw-talkpageheader\">\n$1\n</div>",
- [ 'talkpageheader' ]
- );
- }
+ if ( $this->getTitle()->isTalkPage() && !wfMessage( 'talkpageheader' )->isDisabled() ) {
+ $this->getContext()->getOutput()->wrapWikiMsg(
+ "<div class=\"mw-talkpageheader\">\n$1\n</div>",
+ [ 'talkpageheader' ]
+ );
}
}
$output .= $pendingPTag . '<br />';
$pendingPTag = false;
$this->lastParagraph = 'p';
- } else {
- if ( $this->lastParagraph !== 'p' ) {
- $output .= $this->closeParagraph();
- $pendingPTag = '<p>';
- } else {
- $pendingPTag = '</p><p>';
- }
- }
- } else {
- if ( $pendingPTag ) {
- $output .= $pendingPTag;
- $pendingPTag = false;
- $this->lastParagraph = 'p';
} elseif ( $this->lastParagraph !== 'p' ) {
- $output .= $this->closeParagraph() . '<p>';
- $this->lastParagraph = 'p';
+ $output .= $this->closeParagraph();
+ $pendingPTag = '<p>';
+ } else {
+ $pendingPTag = '</p><p>';
}
+ } elseif ( $pendingPTag ) {
+ $output .= $pendingPTag;
+ $pendingPTag = false;
+ $this->lastParagraph = 'p';
+ } elseif ( $this->lastParagraph !== 'p' ) {
+ $output .= $this->closeParagraph() . '<p>';
+ $this->lastParagraph = 'p';
}
}
}
*/
if ( !( $this->mOptions->getDisableContentConversion()
|| isset( $this->mDoubleUnderscores['nocontentconvert'] ) )
+ && !$this->mOptions->getInterfaceMessage()
) {
- if ( !$this->mOptions->getInterfaceMessage() ) {
- # The position of the convert() call should not be changed. it
- # assumes that the links are all replaced and the only thing left
- # is the <nowiki> mark.
- $text = $this->getTargetLanguage()->convert( $text );
- }
+ # The position of the convert() call should not be changed. it
+ # assumes that the links are all replaced and the only thing left
+ # is the <nowiki> mark.
+ $text = $this->getTargetLanguage()->convert( $text );
}
$text = $this->mStripState->unstripNoWiki( $text );
// if $firstsingleletterword is set, we don't
// look at the other options, so we can bail early.
break;
- } else {
- if ( $firstmultiletterword == -1 ) {
- $firstmultiletterword = $i;
- }
+ } elseif ( $firstmultiletterword == -1 ) {
+ $firstmultiletterword = $i;
}
}
}
* Some of these require message or data lookups and can be
* expensive to check many times.
*/
- if ( Hooks::run( 'ParserGetVariableValueVarCache', [ &$parser, &$this->mVarCache ] ) ) {
- if ( isset( $this->mVarCache[$index] ) ) {
- return $this->mVarCache[$index];
- }
+ if ( Hooks::run( 'ParserGetVariableValueVarCache', [ &$parser, &$this->mVarCache ] )
+ && isset( $this->mVarCache[$index] )
+ ) {
+ return $this->mVarCache[$index];
}
$ts = wfTimestamp( TS_UNIX, $this->mOptions->getTimestamp() );
if ( $paramName === 'no-link' ) {
$value = true;
}
- if ( $paramName === 'link-url' ) {
- if ( $this->mOptions->getExternalLinkTarget() ) {
- $params[$type]['link-target'] = $this->mOptions->getExternalLinkTarget();
- }
+ if ( ( $paramName === 'link-url' ) && $this->mOptions->getExternalLinkTarget() ) {
+ $params[$type]['link-target'] = $this->mOptions->getExternalLinkTarget();
}
}
break;
if ( $sectionIndex == 0 ) {
if ( $mode === 'get' ) {
return '';
- } else {
- return $newText;
}
+
+ return $newText;
} else {
if ( $mode === 'get' ) {
return $newText;
- } else {
- return $text;
}
+
+ return $text;
}
}
*/
public static function stripOuterParagraph( $html ) {
$m = [];
- if ( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $html, $m ) ) {
- if ( strpos( $m[1], '</p>' ) === false ) {
- $html = $m[1];
- }
+ if ( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $html, $m ) && strpos( $m[1], '</p>' ) === false ) {
+ $html = $m[1];
}
return $html;
$badtag = true;
}
}
- } else {
- if ( $t == 'table' ) {
- $tagstack = array_pop( $tablestack );
- }
+ } elseif ( $t == 'table' ) {
+ $tagstack = array_pop( $tablestack );
}
$newparams = '';
} else {
// Use a linebreak between module script and state script (T162719)
$out = $this->ensureNewline( $out ) . $stateScript;
}
- } else {
- if ( $states ) {
- $this->errors[] = 'Problematic modules: '
- . self::encodeJsonForScript( $states );
- }
+ } elseif ( $states ) {
+ $this->errors[] = 'Problematic modules: '
+ . self::encodeJsonForScript( $states );
}
return $out;
// Decide whether to use 'style' or 'script' element
if ( $only === ResourceLoaderModule::TYPE_STYLES ) {
$chunk = Html::linkedStyle( $url );
+ } elseif ( $context->getRaw() || $isRaw ) {
+ $chunk = Html::element( 'script', [
+ // In SpecialJavaScriptTest, QUnit must load synchronous
+ 'async' => !isset( $extraQuery['sync'] ),
+ 'src' => $url
+ ] );
} else {
- if ( $context->getRaw() || $isRaw ) {
- $chunk = Html::element( 'script', [
- // In SpecialJavaScriptTest, QUnit must load synchronous
- 'async' => !isset( $extraQuery['sync'] ),
- 'src' => $url
- ] );
- } else {
- $chunk = ResourceLoader::makeInlineScript(
- Xml::encodeJsCall( 'mw.loader.load', [ $url ] ),
- $nonce
- );
- }
+ $chunk = ResourceLoader::makeInlineScript(
+ Xml::encodeJsCall( 'mw.loader.load', [ $url ] ),
+ $nonce
+ );
}
if ( $group == 'noscript' ) {
$boxes[$boxName]['content'] = $content;
}
}
- } else {
- if ( $hookContents ) {
- $boxes['TOOLBOXEND'] = [
- 'id' => 'p-toolboxend',
- 'header' => $boxes['TOOLBOX']['header'],
- 'generated' => false,
- 'content' => "<ul>{$hookContents}</ul>",
- ];
- // HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
- $boxes2 = [];
- foreach ( $boxes as $key => $box ) {
- if ( $key === 'TOOLBOXEND' ) {
- continue;
- }
- $boxes2[$key] = $box;
- if ( $key === 'TOOLBOX' ) {
- $boxes2['TOOLBOXEND'] = $boxes['TOOLBOXEND'];
- }
+ } elseif ( $hookContents ) {
+ $boxes['TOOLBOXEND'] = [
+ 'id' => 'p-toolboxend',
+ 'header' => $boxes['TOOLBOX']['header'],
+ 'generated' => false,
+ 'content' => "<ul>{$hookContents}</ul>",
+ ];
+ // HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
+ $boxes2 = [];
+ foreach ( $boxes as $key => $box ) {
+ if ( $key === 'TOOLBOXEND' ) {
+ continue;
+ }
+ $boxes2[$key] = $box;
+ if ( $key === 'TOOLBOX' ) {
+ $boxes2['TOOLBOXEND'] = $boxes['TOOLBOXEND'];
}
- $boxes = $boxes2;
- // END hack
}
+ $boxes = $boxes2;
+ // END hack
}
return $boxes;
$tpl->set( 'credits', false );
$tpl->set( 'numberofwatchingusers', false );
if ( $title->exists() ) {
- if ( $out->isArticle() ) {
- if ( $this->isRevisionCurrent() ) {
- if ( $wgMaxCredits != 0 ) {
- /** @var CreditsAction $action */
- $action = Action::factory(
- 'credits', $this->getWikiPage(), $this->getContext() );
- $tpl->set( 'credits',
- $action->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
- } else {
- $tpl->set( 'lastmod', $this->lastModified() );
- }
+ if ( $out->isArticle() && $this->isRevisionCurrent() ) {
+ if ( $wgMaxCredits != 0 ) {
+ /** @var CreditsAction $action */
+ $action = Action::factory(
+ 'credits', $this->getWikiPage(), $this->getContext() );
+ $tpl->set( 'credits',
+ $action->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
+ } else {
+ $tpl->set( 'lastmod', $this->lastModified() );
}
}
if ( $out->showsCopyright() ) {
$message = 'sp-contributions-footer';
}
- if ( $message ) {
- if ( !$this->including() ) {
- if ( !$this->msg( $message, $target )->isDisabled() ) {
- $out->wrapWikiMsg(
- "<div class='mw-contributions-footer'>\n$1\n</div>",
- [ $message, $target ] );
- }
- }
+ if ( $message && !$this->including() && !$this->msg( $message, $target )->isDisabled() ) {
+ $out->wrapWikiMsg(
+ "<div class='mw-contributions-footer'>\n$1\n</div>",
+ [ $message, $target ] );
}
}
}
Xml::closeElement( 'form' ) .
Xml::closeElement( 'fieldset' )
);
- } else {
- if ( empty( $this->importSources ) ) {
- $out->addWikiMsg( 'importnosources' );
- }
+ } elseif ( empty( $this->importSources ) ) {
+ $out->addWikiMsg( 'importnosources' );
}
if ( $user->isAllowed( 'import' ) && !empty( $this->importSources ) ) {
$this->namespaces = $nslist;
} elseif ( $profile === 'advanced' ) {
$this->namespaces = $nslist;
+ } elseif ( isset( $profiles[$profile]['namespaces'] ) ) {
+ $this->namespaces = $profiles[$profile]['namespaces'];
} else {
- if ( isset( $profiles[$profile]['namespaces'] ) ) {
- $this->namespaces = $profiles[$profile]['namespaces'];
- } else {
- // Unknown profile requested
- $profile = 'default';
- $this->namespaces = $profiles['default']['namespaces'];
- }
+ // Unknown profile requested
+ $profile = 'default';
+ $this->namespaces = $profiles['default']['namespaces'];
}
$this->fulltext = $request->getVal( 'fulltext' );
$this->loadRequest();
# Unsave the temporary file in case this was a cancelled upload
- if ( $this->mCancelUpload ) {
- if ( !$this->unsaveUploadedFile() ) {
- # Something went wrong, so unsaveUploadedFile showed a warning
- return;
- }
+ if ( $this->mCancelUpload && !$this->unsaveUploadedFile() ) {
+ # Something went wrong, so unsaveUploadedFile showed a warning
+ return;
}
# Process upload or show a form
&& ( $hidetrans || !$tlRes->numRows() )
&& ( $hideimages || !$ilRes->numRows() )
) {
- if ( $level == 0 ) {
- if ( !$this->including() ) {
- $out->addHTML( $this->whatlinkshereForm() );
-
- // Show filters only if there are links
- if ( $hidelinks || $hidetrans || $hideredirs || $hideimages ) {
- $out->addHTML( $this->getFilterPanel() );
- }
- $msgKey = is_int( $namespace ) ? 'nolinkshere-ns' : 'nolinkshere';
- $link = $this->getLinkRenderer()->makeLink(
- $this->target,
- null,
- [],
- $this->target->isRedirect() ? [ 'redirect' => 'no' ] : []
- );
-
- $errMsg = $this->msg( $msgKey )
- ->params( $this->target->getPrefixedText() )
- ->rawParams( $link )
- ->parseAsBlock();
- $out->addHTML( $errMsg );
- $out->setStatusCode( 404 );
+ if ( $level == 0 && !$this->including() ) {
+ $out->addHTML( $this->whatlinkshereForm() );
+
+ // Show filters only if there are links
+ if ( $hidelinks || $hidetrans || $hideredirs || $hideimages ) {
+ $out->addHTML( $this->getFilterPanel() );
}
+ $msgKey = is_int( $namespace ) ? 'nolinkshere-ns' : 'nolinkshere';
+ $link = $this->getLinkRenderer()->makeLink(
+ $this->target,
+ null,
+ [],
+ $this->target->isRedirect() ? [ 'redirect' => 'no' ] : []
+ );
+
+ $errMsg = $this->msg( $msgKey )
+ ->params( $this->target->getPrefixedText() )
+ ->rawParams( $link )
+ ->parseAsBlock();
+ $out->addHTML( $errMsg );
+ $out->setStatusCode( 404 );
}
return;
}
$lb->execute();
- if ( $level == 0 ) {
- if ( !$this->including() ) {
- $out->addHTML( $this->whatlinkshereForm() );
- $out->addHTML( $this->getFilterPanel() );
+ if ( $level == 0 && !$this->including() ) {
+ $out->addHTML( $this->whatlinkshereForm() );
+ $out->addHTML( $this->getFilterPanel() );
- $link = $this->getLinkRenderer()->makeLink(
- $this->target,
- null,
- [],
- $this->target->isRedirect() ? [ 'redirect' => 'no' ] : []
- );
+ $link = $this->getLinkRenderer()->makeLink(
+ $this->target,
+ null,
+ [],
+ $this->target->isRedirect() ? [ 'redirect' => 'no' ] : []
+ );
- $msg = $this->msg( 'linkshere' )
- ->params( $this->target->getPrefixedText() )
- ->rawParams( $link )
- ->parseAsBlock();
- $out->addHTML( $msg );
+ $msg = $this->msg( 'linkshere' )
+ ->params( $this->target->getPrefixedText() )
+ ->rawParams( $link )
+ ->parseAsBlock();
+ $out->addHTML( $msg );
- $prevnext = $this->getPrevNext( $prevId, $nextId );
- $out->addHTML( $prevnext );
- }
+ $prevnext = $this->getPrevNext( $prevId, $nextId );
+ $out->addHTML( $prevnext );
}
$out->addHTML( $this->listStart( $level ) );
foreach ( $rows as $row ) {
$out->addHTML( $this->listEnd() );
- if ( $level == 0 ) {
- if ( !$this->including() ) {
- $out->addHTML( $prevnext );
- }
+ if ( $level == 0 && !$this->including() ) {
+ $out->addHTML( $prevnext );
}
}
case 'ipb_params':
$properties = [];
- if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
- if ( $row->ipb_sitewide ) {
- $properties[] = htmlspecialchars( $msg['blocklist-editing-sitewide'] );
- }
+ if ( $this->getConfig()->get( 'EnablePartialBlocks' ) && $row->ipb_sitewide ) {
+ $properties[] = htmlspecialchars( $msg['blocklist-editing-sitewide'] );
}
if ( !$row->ipb_sitewide && $this->restrictions ) {
}
}
$fields['top'] = $dbr->addQuotes( 'no' );
- } else {
- if ( $this->mShowAll ) {
- $fields['top'] = $dbr->addQuotes( 'yes' );
- }
+ } elseif ( $this->mShowAll ) {
+ $fields['top'] = $dbr->addQuotes( 'yes' );
}
$fields['thumb'] = $prefix . '_name';
$resultArray[] = $topRes2;
$topRes2 = $res2->next();
}
+ } elseif ( !$ascending ) {
+ $resultArray[] = $topRes2;
+ $topRes2 = $res2->next();
} else {
- if ( !$ascending ) {
- $resultArray[] = $topRes2;
- $topRes2 = $res2->next();
- } else {
- $resultArray[] = $topRes1;
- $topRes1 = $res1->next();
- }
+ $resultArray[] = $topRes1;
+ $topRes1 = $res1->next();
}
}
$name = $node->name;
$attrs = $node->attrs;
- if ( isset( self::$markedEmptyElements[$name] ) && $attrs->count() === 0 ) {
- if ( strspn( $contents, "\t\n\f\r " ) === strlen( $contents ) ) {
- return "<{$name} class=\"mw-empty-elt\">$contents</{$name}>";
- }
+ if ( isset( self::$markedEmptyElements[$name] ) && $attrs->count() === 0
+ && strspn( $contents, "\t\n\f\r " ) === strlen( $contents )
+ ) {
+ return "<{$name} class=\"mw-empty-elt\">$contents</{$name}>";
}
$s = "<$name";
# Can't make a link to a namespace alone... "empty" local links can only be
# self-links with a fragment identifier.
- if ( $dbkey == '' && $parts['interwiki'] === '' ) {
- if ( $parts['namespace'] != NS_MAIN ) {
- throw new MalformedTitleException( 'title-invalid-empty', $text );
- }
+ if ( $dbkey == '' && $parts['interwiki'] === '' && $parts['namespace'] != NS_MAIN ) {
+ throw new MalformedTitleException( 'title-invalid-empty', $text );
}
// Allow IPv6 usernames to start with '::' by canonicalizing IPv6 titles.
$props = $this->mFileProps;
$error = null;
Hooks::run( 'UploadStashFile', [ $this, $user, $props, &$error ] );
- if ( $error ) {
- if ( !is_array( $error ) ) {
- $error = [ $error ];
- }
+ if ( $error && !is_array( $error ) ) {
+ $error = [ $error ];
}
return $error;
}
$output = true; # if there's no output, return true
} elseif ( $msgPattern ) {
$groups = [];
- if ( preg_match( $msgPattern, $output, $groups ) ) {
- if ( $groups[1] ) {
- $output = $groups[1];
- }
+ if ( preg_match( $msgPattern, $output, $groups ) && $groups[1] ) {
+ $output = $groups[1];
}
}
);
}
- if ( !$noAuth ) {
- if ( $this->fileMetadata[$key]['us_user'] != $this->userId ) {
- throw new UploadStashWrongOwnerException(
- wfMessage( 'uploadstash-wrong-owner', $key )
- );
- }
+ if ( !$noAuth && $this->fileMetadata[$key]['us_user'] != $this->userId ) {
+ throw new UploadStashWrongOwnerException(
+ wfMessage( 'uploadstash-wrong-owner', $key )
+ );
}
return $this->files[$key];
public function trackBlockWithCookie() {
$block = $this->getBlock();
- if ( $block && $this->getRequest()->getCookie( 'BlockID' ) === null ) {
- if ( $block->shouldTrackWithCookie( $this->isAnon() ) ) {
- $block->setCookie( $this->getRequest()->response() );
- }
+ if ( $block && $this->getRequest()->getCookie( 'BlockID' ) === null
+ && $block->shouldTrackWithCookie( $this->isAnon() )
+ ) {
+ $block->setCookie( $this->getRequest()->response() );
}
}
[ 'LOCK IN SHARE MODE' ]
);
$loaded = false;
- if ( $this->mId ) {
- if ( $this->loadFromDatabase( self::READ_LOCKING ) ) {
- $loaded = true;
- }
+ if ( $this->mId && $this->loadFromDatabase( self::READ_LOCKING ) ) {
+ $loaded = true;
}
if ( !$loaded ) {
throw new MWException( $fname . ": hit a key conflict attempting " .
$conds = array_merge( $conds, $this->getStartEndConds( $db, $options ) );
- if ( !isset( $options['start'] ) && !isset( $options['end'] ) ) {
- if ( $db->getType() === 'mysql' ) {
- // This is an index optimization for mysql
- $conds[] = 'rc_timestamp > ' . $db->addQuotes( '' );
- }
+ if ( !isset( $options['start'] ) && !isset( $options['end'] ) && $db->getType() === 'mysql' ) {
+ // This is an index optimization for mysql
+ $conds[] = 'rc_timestamp > ' . $db->addQuotes( '' );
}
$conds = array_merge( $conds, $this->getUserRelatedConds( $db, $user, $options ) );
* @dataProvider provideExecute
*/
public function testExecute( $testCommand, $flag ) {
- if ( preg_match( '/^sudo /', $testCommand ) ) {
- if ( Shell::command( 'sudo', '-n', 'ls', '/' )->execute()->getExitCode() ) {
- $this->markTestSkipped( 'need passwordless sudo' );
- }
+ if ( preg_match( '/^sudo /', $testCommand )
+ && Shell::command( 'sudo', '-n', 'ls', '/' )->execute()->getExitCode()
+ ) {
+ $this->markTestSkipped( 'need passwordless sudo' );
}
$command = new FirejailCommand( 'firejail' );
'old_text' => 'Hello World',
'old_flags' => 'utf-8',
];
- } else {
- if ( !isset( $row['content'] ) && isset( $array['old_text'] ) ) {
- $row['content'] = [
- 'main' => new WikitextContent( $array['old_text'] ),
- ];
- }
+ } elseif ( !isset( $row['content'] ) && isset( $array['old_text'] ) ) {
+ $row['content'] = [
+ 'main' => new WikitextContent( $array['old_text'] ),
+ ];
}
return (object)$row;
if ( $value instanceof $type ) {
return;
}
- } else {
- if ( gettype( $value ) === $type ) {
- return;
- }
+ } elseif ( gettype( $value ) === $type ) {
+ return;
}
} else {
// Array whose values have specified types, recurse
// 'class Foo {}'
$class = $fileNamespace . $match['class'];
$classesInFile[$class] = true;
+ } elseif ( !empty( $match['original'] ) ) {
+ // 'class_alias( "Foo", "Bar" );'
+ $aliasesInFile[$match['alias']] = $match['original'];
} else {
- if ( !empty( $match['original'] ) ) {
- // 'class_alias( "Foo", "Bar" );'
- $aliasesInFile[$match['alias']] = $match['original'];
- } else {
- // 'class_alias( Foo::class, "Bar" );'
- $aliasesInFile[$match['aliasString']] = $fileNamespace . $match['originalStatic'];
- }
+ // 'class_alias( Foo::class, "Bar" );'
+ $aliasesInFile[$match['aliasString']] = $fileNamespace . $match['originalStatic'];
}
}